package ExProjectI;

import java.io.FileOutputStream;
import java.io.IOException;

public class TestWrite {
	public static void main(String [] args) {

        // The name of the file to create.
        String fileName = "C:\\Users\\Sherlock Quys\\Documents\\Java Source Code\\MyFile.txt";

        try {
           /*Nhap doan van ban ma ban muon sua cho file moi
            * 
            */
            String bytes = "Hello there\n";
            byte[] buffer = bytes.getBytes();

            FileOutputStream outputStream =
                new FileOutputStream(fileName);

            // write() writes as many bytes from the buffer
            // as the length of the buffer. You can also
            // use
            // write(buffer, offset, length)
            // if you want to write a specific number of
            // bytes, or only part of the buffer.
            outputStream.write(buffer);

            // Always close files.
            outputStream.close();		

            System.out.println("Wrote " + buffer.length + 
                " bytes");
        }
        catch(IOException ex) {
            System.out.println(
                "Error writing file '"
                + fileName + "'");
            // Or we could just do this:
            // ex.printStackTrace();
        }
    }
}
